<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人信息 - 权限管理系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #667eea;
            --secondary-color: #764ba2;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f8fafc;
        }

        .sidebar {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            color: white;
            height: 100vh;
            position: fixed;
            width: 280px;
            box-shadow: 5px 0 15px rgba(0,0,0,0.1);
            z-index: 1000;
        }

        .main-content {
            margin-left: 280px;
            padding: 30px;
            min-height: 100vh;
        }

        .nav-link {
            color: rgba(255,255,255,0.9) !important;
            padding: 15px 25px;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            transition: all 0.3s ease;
            font-weight: 500;
        }

        .nav-link:hover {
            background: rgba(255,255,255,0.15);
            padding-left: 30px;
            color: white !important;
        }

        .nav-link.active {
            background: rgba(255,255,255,0.2);
            border-left: 4px solid white;
            color: white !important;
        }

        .profile-card {
            background: white;
            border-radius: 15px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.08);
            overflow: hidden;
        }

        .profile-header {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            color: white;
            padding: 40px;
            text-align: center;
        }

        .profile-avatar {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background: rgba(255,255,255,0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 20px;
            font-size: 2.5rem;
        }

        .info-item {
            padding: 15px 20px;
            border-bottom: 1px solid #f1f5f9;
        }

        .info-item:last-child {
            border-bottom: none;
        }

        .info-label {
            font-weight: 600;
            color: #64748b;
            min-width: 100px;
        }

        .role-badge {
            margin: 2px;
            font-size: 0.75rem;
            padding: 4px 8px;
        }
    </style>
</head>
<body>
<!-- 侧边栏 -->
<div class="sidebar">
    <div class="p-4">
        <div class="d-flex align-items-center mb-3">
            <div style="width: 50px; height: 50px; border-radius: 12px; background: white; display: flex; align-items: center; justify-content: center;" class="me-3">
                <i class="fas fa-shield-alt text-primary"></i>
            </div>
            <div>
                <h5 class="mb-0">权限管理系统</h5>
                <small class="opacity-75">个人信息</small>
            </div>
        </div>
        <p class="mb-0 text-light opacity-75">
            <i class="fas fa-user me-2"></i><span th:text="${user.name}">用户</span>
        </p>
    </div>
    <nav class="nav flex-column">
        <a class="nav-link" href="/dashboard">
            <i class="fas fa-home me-3"></i>系统首页
        </a>
        <a class="nav-link" href="/user/management">
            <i class="fas fa-users me-3"></i>用户管理
        </a>
        <a class="nav-link" href="/role/management">
            <i class="fas fa-user-shield me-3"></i>权限管理
        </a>
        <a class="nav-link active" href="/user/profile">
            <i class="fas fa-user-cog me-3"></i>个人信息
        </a>
        <a class="nav-link" href="/logout">
            <i class="fas fa-sign-out-alt me-3"></i>退出登录
        </a>
    </nav>
</div>

<!-- 主内容区 -->
<div class="main-content">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h2 class="mb-1">
                <i class="fas fa-user-cog me-2 text-primary"></i>个人信息
            </h2>
            <p class="text-muted mb-0">查看和编辑个人账户信息</p>
        </div>
        <button class="btn btn-primary">
            <i class="fas fa-edit me-2"></i>编辑信息
        </button>
    </div>

    <div class="profile-card" th:if="${user}">
        <div class="profile-header">
            <div class="profile-avatar">
                <i class="fas fa-user"></i>
            </div>
            <h3 th:text="${user.name}">用户姓名</h3>
            <p class="mb-0 opacity-75" th:text="${user.loginname}">用户名</p>
        </div>

        <div class="p-4">
            <h5 class="mb-4">
                <i class="fas fa-id-card me-2 text-primary"></i>基本信息
            </h5>
            <div class="info-item d-flex">
                <span class="info-label">用户ID：</span>
                <span th:text="${user.id}">1</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">登录名：</span>
                <span th:text="${user.loginname}">admin</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">姓名：</span>
                <span th:text="${user.name}">管理员</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">邮箱：</span>
                <span th:text="${user.email}">admin@example.com</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">手机号：</span>
                <span th:text="${user.mobilephone}">13800138000</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">性别：</span>
                <span th:if="${user.sex == 1}" class="badge bg-primary">男</span>
                <span th:if="${user.sex == 2}" class="badge bg-pink">女</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">状态：</span>
                <span th:if="${user.status == 0}" class="badge bg-success">正常</span>
                <span th:if="${user.status == 1}" class="badge bg-danger">禁用</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">地址：</span>
                <span th:text="${user.address != null} ? ${user.address} : '未填写'">北京市朝阳区</span>
            </div>
            <div class="info-item d-flex">
                <span class="info-label">创建时间：</span>
                <span th:text="${#temporals.format(user.createTime, 'yyyy-MM-dd HH:mm')}">2024-01-01 10:00</span>
            </div>

            <h5 class="mt-5 mb-4">
                <i class="fas fa-user-shield me-2 text-success"></i>角色信息
            </h5>
            <div class="info-item">
                <div class="d-flex flex-wrap">
                    <div th:each="role : ${user.roles}">
                            <span class="badge role-badge"
                                  th:class="${role.roleKey == 'super_admin'} ? 'bg-danger' :
                                             (${role.roleKey == 'admin'} ? 'bg-warning' :
                                             (${role.roleKey == 'manager'} ? 'bg-success' : 'bg-info'))"
                                  th:text="${role.name}">
                                角色
                            </span>
                    </div>
                    <div th:if="${user.roles == null or user.roles.isEmpty()}">
                        <span class="text-muted">暂无角色</span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="profile-card" th:unless="${user}">
        <div class="card-body text-center py-5">
            <i class="fas fa-exclamation-triangle fa-3x text-warning mb-3"></i>
            <h5 class="text-muted">用户信息不存在</h5>
            <p class="text-muted">无法获取用户信息，请重新登录</p>
            <a href="/logout" class="btn btn-primary mt-3">
                <i class="fas fa-sign-in-alt me-2"></i>重新登录
            </a>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>